'use strict'

let actionDispatch = {
    login: true,
    handler(req, res) {
        let user = req.session.login.user;
        if ( user.role.name == 'student' ) {
            res.redirect('/student/index/today');
        }
        else if ( user.role.name == 'teacher' ) {
            res.redirect('/teacher/index/index');
        }
        else if ( user.role.name == 'leader' ) {
            res.redirect('/leader/index/index');
        }
        else if ( user.role.name == 'leaderTeacher' ) {
            res.redirect('/leader/index/index');
        }
        else {
            res.send('Role not supported');
        }
    }
};

module.exports = {
    actionDispatch
}
